package com.chapter03;

import com.bdqn.util.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

public class Test03_Delete {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        Connection connection = JDBCUtils.getConnection();
//        Statement statement = connection.createStatement();
//        String sql = "DELETE FROM grade WHERE GradeId = 104;";
//
//        int i = statement.executeUpdate(sql);
        String sql = "DELETE FROM grade WHERE GradeId = ?;";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setObject(1,104);
        int i = preparedStatement.executeUpdate();
        if (i>0){
            System.out.println("删除成功");
        }

        preparedStatement.close();
        connection.close();
    }
}
